import { CreateDeptDto } from 'src/module/system/dept/dto';
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
import { CategoryEntity } from '../../categories/entities/shop-category.entity';

@Entity('shop_product')
export class ProductEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 200, comment: '商品名称' })
  name: string;

  @Column({ type: 'decimal', precision: 10, scale: 2 })
  price: number;

  @Column({ type: 'text', nullable: true, comment: '商品描述' })
  description: string;

  @Column({ nullable: true, comment: '商品主图' })
  mainImage: string;

  @Column('simple-array', { nullable: true, comment: '轮播图' })
  carouselImages: string[];

  @Column({ type: 'longtext', nullable: true, comment: '商品详情' })
  detailHtml: string;

  @Column({ default: true, comment: '是否启用' })
  isActive: boolean;

  @ManyToOne(() => CategoryEntity, (category) => category.products)
  category: CategoryEntity;

  @CreateDateColumn({ comment: '创建时间' })
  createTime: Date;

  @UpdateDateColumn({ comment: '更新时间' })
  updateTime: Date;
}
